
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/tutorial/printing.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:23:54 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Printing &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../live.sympy.org/static/live-sphinx.js"></script>
    <script async="async" src="../../../cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest8331.js?config=TeX-AMS_HTML-full"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]]}})</script>
    
    <link rel="shortcut icon" href="../_static/sympy-notailtext-favicon.ico"/>
    <link href="printing.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Simplification" href="simplification.html" />
    <link rel="prev" title="Basic Operations" href="basic_operations.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="simplification.html" title="Simplification"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="basic_operations.html" title="Basic Operations"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">SymPy Tutorial</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Printing</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="printing">
<span id="tutorial-printing"></span><h1>Printing<a class="headerlink" href="#printing" title="Permalink to this headline">¶</a></h1>
<p>As we have already seen, SymPy can pretty print its output using Unicode
characters.  This is a short introduction to the most common printing options
available in SymPy.</p>
<section id="printers">
<h2>Printers<a class="headerlink" href="#printers" title="Permalink to this headline">¶</a></h2>
<p>There are several printers available in SymPy.  The most common ones are</p>
<ul class="simple">
<li><p>str</p></li>
<li><p>srepr</p></li>
<li><p>ASCII pretty printer</p></li>
<li><p>Unicode pretty printer</p></li>
<li><p>LaTeX</p></li>
<li><p>MathML</p></li>
<li><p>Dot</p></li>
</ul>
<p>In addition to these, there are also “printers” that can output SymPy objects
to code, such as C, Fortran, Javascript, Theano, and Python.  These are not
discussed in this tutorial.</p>
</section>
<section id="setting-up-pretty-printing">
<h2>Setting up Pretty Printing<a class="headerlink" href="#setting-up-pretty-printing" title="Permalink to this headline">¶</a></h2>
<p>If all you want is the best pretty printing, use the <code class="docutils literal notranslate"><span class="pre">init_printing()</span></code>
function.  This will automatically enable the best printer available in your
environment.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">init_printing</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_printing</span><span class="p">()</span> 
</pre></div>
</div>
<aside class="sidebar">
<p class="sidebar-title">Quick Tip</p>
<p>You can also change the printer used in SymPy Live. Just change the “Output
Format” in the settings.</p>
</aside>
<p>If you plan to work in an interactive calculator-type session, the
<code class="docutils literal notranslate"><span class="pre">init_session()</span></code> function will automatically import everything in SymPy,
create some common Symbols, setup plotting, and run <code class="docutils literal notranslate"><span class="pre">init_printing()</span></code>.</p>
<blockquote>
<div><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">init_session</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_session</span><span class="p">()</span> 
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Python</span> <span class="n">console</span> <span class="k">for</span> <span class="n">SymPy</span> <span class="mf">0.7.3</span> <span class="p">(</span><span class="n">Python</span> <span class="mf">2.7.5</span><span class="o">-</span><span class="mi">64</span><span class="o">-</span><span class="n">bit</span><span class="p">)</span> <span class="p">(</span><span class="n">ground</span> <span class="n">types</span><span class="p">:</span> <span class="n">gmpy</span><span class="p">)</span>

<span class="n">These</span> <span class="n">commands</span> <span class="n">were</span> <span class="n">executed</span><span class="p">:</span>
<span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">division</span>
<span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="o">*</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">,</span> <span class="n">t</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x y z t&#39;</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">k</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">n</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;k m n&#39;</span><span class="p">,</span> <span class="n">integer</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">,</span> <span class="n">h</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;f g h&#39;</span><span class="p">,</span> <span class="bp">cls</span><span class="o">=</span><span class="n">Function</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">init_printing</span><span class="p">()</span> <span class="c1"># doctest: +SKIP</span>

<span class="n">Documentation</span> <span class="n">can</span> <span class="n">be</span> <span class="n">found</span> <span class="n">at</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">www</span><span class="o">.</span><span class="n">sympy</span><span class="o">.</span><span class="n">org</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="go">&gt;&gt;&gt;</span>
</pre></div>
</div>
</div></blockquote>
<p>In any case, this is what will happen:</p>
<ul>
<li><p>In the IPython QTConsole, if <span class="math notranslate nohighlight">\(\mathrm{\LaTeX}\)</span> is installed, it will enable a printer
that uses <span class="math notranslate nohighlight">\(\mathrm{\LaTeX}\)</span>.</p>
<a class="reference internal image-reference" href="../_images/ipythonqtconsole.png"><img alt="../_images/ipythonqtconsole.png" src="../_images/ipythonqtconsole.png" style="height: 500px;" /></a>
<p>If <span class="math notranslate nohighlight">\(\mathrm{\LaTeX}\)</span> is not installed, but Matplotlib is installed, it will use the
Matplotlib rendering engine. If Matplotlib is not installed, it uses the
Unicode pretty printer.</p>
</li>
<li><p>In the IPython notebook, it will use MathJax to render <span class="math notranslate nohighlight">\(\mathrm{\LaTeX}\)</span>.</p>
<a class="reference internal image-reference" href="../_images/ipythonnotebook.png"><img alt="../_images/ipythonnotebook.png" src="../_images/ipythonnotebook.png" style="height: 250px;" /></a>
</li>
<li><p>In an IPython console session, or a regular Python session, it will use the
Unicode pretty printer if the terminal supports Unicode.</p>
<a class="reference internal image-reference" href="../_images/consoleunicode.png"><img alt="../_images/consoleunicode.png" src="../_images/consoleunicode.png" style="width: 700px;" /></a>
</li>
<li><p>In a terminal that does not support Unicode, the ASCII pretty printer is
used.</p>
<a class="reference internal image-reference" href="../_images/consoleascii.png"><img alt="../_images/consoleascii.png" src="../_images/consoleascii.png" style="width: 700px;" /></a>
</li>
</ul>
<p>To explicitly not use <span class="math notranslate nohighlight">\(\mathrm{\LaTeX}\)</span>, pass <code class="docutils literal notranslate"><span class="pre">use_latex=False</span></code> to <code class="docutils literal notranslate"><span class="pre">init_printing()</span></code>
or <code class="docutils literal notranslate"><span class="pre">init_session()</span></code>.  To explicitly not use Unicode, pass
<code class="docutils literal notranslate"><span class="pre">use_unicode=False</span></code>.</p>
</section>
<section id="printing-functions">
<h2>Printing Functions<a class="headerlink" href="#printing-functions" title="Permalink to this headline">¶</a></h2>
<p>In addition to automatic printing, you can explicitly use any one of the
printers by calling the appropriate function.</p>
<section id="str">
<h3>str<a class="headerlink" href="#str" title="Permalink to this headline">¶</a></h3>
<p>To get a string form of an expression, use <code class="docutils literal notranslate"><span class="pre">str(expr)</span></code>.  This is also the
form that is produced by <code class="docutils literal notranslate"><span class="pre">print(expr)</span></code>.  String forms are designed to be
easy to read, but in a form that is correct Python syntax so that it can be
copied and pasted.  The <code class="docutils literal notranslate"><span class="pre">str()</span></code> form of an expression will usually look
exactly the same as the expression as you would enter it.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="o">*</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x y z&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">str</span><span class="p">(</span><span class="n">Integral</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">))</span>
<span class="go">&#39;Integral(sqrt(1/x), x)&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">Integral</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Integral(sqrt(1/x), x)</span>
</pre></div>
</div>
</section>
<section id="srepr">
<h3>srepr<a class="headerlink" href="#srepr" title="Permalink to this headline">¶</a></h3>
<p>The srepr form of an expression is designed to show the exact form of an
expression.  It will be discussed more in the <a class="reference internal" href="manipulation.html#tutorial-manipulation"><span class="std std-ref">Advanced Expression Manipulation</span></a>
section.  To get it, use <code class="docutils literal notranslate"><span class="pre">srepr()</span></code> <a class="footnote-reference brackets" href="#srepr-fn" id="id1">1</a>.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">srepr</span><span class="p">(</span><span class="n">Integral</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">))</span>
<span class="go">&quot;Integral(Pow(Pow(Symbol(&#39;x&#39;), Integer(-1)), Rational(1, 2)), Tuple(Symbol(&#39;x&#39;)))&quot;</span>
</pre></div>
</div>
<p>The srepr form is mostly useful for understanding how an expression is built
internally.</p>
</section>
<section id="ascii-pretty-printer">
<h3>ASCII Pretty Printer<a class="headerlink" href="#ascii-pretty-printer" title="Permalink to this headline">¶</a></h3>
<p>The ASCII pretty printer is accessed from <code class="docutils literal notranslate"><span class="pre">pprint()</span></code>.  If the terminal does
not support Unicode, the ASCII printer is used by default.  Otherwise, you
must pass <code class="docutils literal notranslate"><span class="pre">use_unicode=False</span></code>.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">Integral</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">),</span> <span class="n">use_unicode</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">  /</span>
<span class="go"> |</span>
<span class="go"> |     ___</span>
<span class="go"> |    / 1</span>
<span class="go"> |   /  -  dx</span>
<span class="go"> | \/   x</span>
<span class="go"> |</span>
<span class="go">/</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">pprint()</span></code> prints the output to the screen.  If you want the string form,
use <code class="docutils literal notranslate"><span class="pre">pretty()</span></code>.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pretty</span><span class="p">(</span><span class="n">Integral</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">),</span> <span class="n">use_unicode</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">&#39;  /          \n |           \n |     ___   \n |    / 1    \n |   /  -  dx\n | \\/   x    \n |           \n/            &#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">pretty</span><span class="p">(</span><span class="n">Integral</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">),</span> <span class="n">use_unicode</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span>
<span class="go">  /</span>
<span class="go"> |</span>
<span class="go"> |     ___</span>
<span class="go"> |    / 1</span>
<span class="go"> |   /  -  dx</span>
<span class="go"> | \/   x</span>
<span class="go"> |</span>
<span class="go">/</span>
</pre></div>
</div>
</section>
<section id="unicode-pretty-printer">
<h3>Unicode Pretty Printer<a class="headerlink" href="#unicode-pretty-printer" title="Permalink to this headline">¶</a></h3>
<p>The Unicode pretty printer is also accessed from <code class="docutils literal notranslate"><span class="pre">pprint()</span></code> and
<code class="docutils literal notranslate"><span class="pre">pretty()</span></code>.  If the terminal supports Unicode, it is used automatically.  If
<code class="docutils literal notranslate"><span class="pre">pprint()</span></code> is not able to detect that the terminal supports unicode, you can
pass <code class="docutils literal notranslate"><span class="pre">use_unicode=True</span></code> to force it to use Unicode.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">Integral</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">),</span> <span class="n">use_unicode</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">⌠</span>
<span class="go">⎮     ___</span>
<span class="go">⎮    ╱ 1</span>
<span class="go">⎮   ╱  ─  dx</span>
<span class="go">⎮ ╲╱   x</span>
<span class="go">⌡</span>
</pre></div>
</div>
</section>
<section id="mathrm-latex">
<span id="latex"></span><h3><span class="math notranslate nohighlight">\(\mathrm{\LaTeX}\)</span><a class="headerlink" href="#mathrm-latex" title="Permalink to this headline">¶</a></h3>
<p>To get the <span class="math notranslate nohighlight">\(\mathrm{\LaTeX}\)</span> form of an expression, use <code class="docutils literal notranslate"><span class="pre">latex()</span></code>.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">latex</span><span class="p">(</span><span class="n">Integral</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">)))</span>
<span class="go">\int \sqrt{\frac{1}{x}}\, dx</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">latex()</span></code> function has many options to change the formatting of
different things.  See <a class="reference internal" href="../modules/printing.html#sympy.printing.latex.latex" title="sympy.printing.latex.latex"><code class="xref py py-meth docutils literal notranslate"><span class="pre">its</span> <span class="pre">documentation</span></code></a> for more details.</p>
</section>
<section id="mathml">
<h3>MathML<a class="headerlink" href="#mathml" title="Permalink to this headline">¶</a></h3>
<p>There is also a printer to MathML, called <code class="docutils literal notranslate"><span class="pre">print_mathml()</span></code>.  It must be
imported from <code class="docutils literal notranslate"><span class="pre">sympy.printing.mathml</span></code>.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.printing.mathml</span> <span class="kn">import</span> <span class="n">print_mathml</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">print_mathml</span><span class="p">(</span><span class="n">Integral</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">))</span>
<span class="go">&lt;apply&gt;</span>
<span class="go">    &lt;int/&gt;</span>
<span class="go">    &lt;bvar&gt;</span>
<span class="go">        &lt;ci&gt;x&lt;/ci&gt;</span>
<span class="go">    &lt;/bvar&gt;</span>
<span class="go">    &lt;apply&gt;</span>
<span class="go">        &lt;root/&gt;</span>
<span class="go">        &lt;apply&gt;</span>
<span class="go">            &lt;power/&gt;</span>
<span class="go">            &lt;ci&gt;x&lt;/ci&gt;</span>
<span class="go">            &lt;cn&gt;-1&lt;/cn&gt;</span>
<span class="go">        &lt;/apply&gt;</span>
<span class="go">    &lt;/apply&gt;</span>
<span class="go">&lt;/apply&gt;</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">print_mathml()</span></code> prints the output.  If you want the string, use the
function <code class="docutils literal notranslate"><span class="pre">mathml()</span></code>.</p>
</section>
<section id="dot">
<h3>Dot<a class="headerlink" href="#dot" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">dotprint()</span></code> function in <code class="docutils literal notranslate"><span class="pre">sympy.printing.dot</span></code> prints output to dot
format, which can be rendered with Graphviz.  See the
<a class="reference internal" href="manipulation.html#tutorial-manipulation"><span class="std std-ref">Advanced Expression Manipulation</span></a> section for some examples of the output of this
printer.</p>
<p>Here is an example of the raw output of the <code class="docutils literal notranslate"><span class="pre">dotprint()</span></code> function</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.printing.dot</span> <span class="kn">import</span> <span class="n">dotprint</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">dotprint</span><span class="p">(</span><span class="n">x</span><span class="o">+</span><span class="mi">2</span><span class="p">))</span>
<span class="go">digraph{</span>

<span class="go"># Graph style</span>
<span class="go">&quot;ordering&quot;=&quot;out&quot;</span>
<span class="go">&quot;rankdir&quot;=&quot;TD&quot;</span>

<span class="go">#########</span>
<span class="go"># Nodes #</span>
<span class="go">#########</span>

<span class="go">&quot;Add(Integer(2), Symbol(&#39;x&#39;))_()&quot; [&quot;color&quot;=&quot;black&quot;, &quot;label&quot;=&quot;Add&quot;, &quot;shape&quot;=&quot;ellipse&quot;];</span>
<span class="go">&quot;Integer(2)_(0,)&quot; [&quot;color&quot;=&quot;black&quot;, &quot;label&quot;=&quot;2&quot;, &quot;shape&quot;=&quot;ellipse&quot;];</span>
<span class="go">&quot;Symbol(&#39;x&#39;)_(1,)&quot; [&quot;color&quot;=&quot;black&quot;, &quot;label&quot;=&quot;x&quot;, &quot;shape&quot;=&quot;ellipse&quot;];</span>

<span class="go">#########</span>
<span class="go"># Edges #</span>
<span class="go">#########</span>

<span class="go">&quot;Add(Integer(2), Symbol(&#39;x&#39;))_()&quot; -&gt; &quot;Integer(2)_(0,)&quot;;</span>
<span class="go">&quot;Add(Integer(2), Symbol(&#39;x&#39;))_()&quot; -&gt; &quot;Symbol(&#39;x&#39;)_(1,)&quot;;</span>
<span class="go">}</span>
</pre></div>
</div>
<p class="rubric">Footnotes</p>
<dl class="footnote brackets">
<dt class="label" id="srepr-fn"><span class="brackets"><a class="fn-backref" href="#id1">1</a></span></dt>
<dd><p>SymPy does not use the Python builtin <code class="docutils literal notranslate"><span class="pre">repr()</span></code> function for
repr printing, because in Python <code class="docutils literal notranslate"><span class="pre">str(list)</span></code> calls <code class="docutils literal notranslate"><span class="pre">repr()</span></code> on the
elements of the list, and some SymPy functions return lists (such as
<code class="docutils literal notranslate"><span class="pre">solve()</span></code>).  Since <code class="docutils literal notranslate"><span class="pre">srepr()</span></code> is so verbose, it is unlikely that anyone
would want it called by default on the output of <code class="docutils literal notranslate"><span class="pre">solve()</span></code>.</p>
</dd>
</dl>
</section>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Printing</a><ul>
<li><a class="reference internal" href="#printers">Printers</a></li>
<li><a class="reference internal" href="#setting-up-pretty-printing">Setting up Pretty Printing</a></li>
<li><a class="reference internal" href="#printing-functions">Printing Functions</a><ul>
<li><a class="reference internal" href="#str">str</a></li>
<li><a class="reference internal" href="#srepr">srepr</a></li>
<li><a class="reference internal" href="#ascii-pretty-printer">ASCII Pretty Printer</a></li>
<li><a class="reference internal" href="#unicode-pretty-printer">Unicode Pretty Printer</a></li>
<li><a class="reference internal" href="#mathrm-latex"><span class="math notranslate nohighlight">\(\mathrm{\LaTeX}\)</span></a></li>
<li><a class="reference internal" href="#mathml">MathML</a></li>
<li><a class="reference internal" href="#dot">Dot</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="basic_operations.html"
                        title="previous chapter">Basic Operations</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="simplification.html"
                        title="next chapter">Simplification</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/tutorial/printing.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="simplification.html" title="Simplification"
             >next</a> |</li>
        <li class="right" >
          <a href="basic_operations.html" title="Basic Operations"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" >SymPy Tutorial</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Printing</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/tutorial/printing.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:23:56 GMT -->
</html>